<script setup>
  import {ref} from "vue";
  const productArr = ref([
    {title:'iPhone',price:5000,count:20},
    {title:'VPhone',price:5000,count:20},
    {title:'OPhone',price:5000,count:20},
    {title:'MPhone',price:5000,count:20},
  ]);
  const del = (index)=>{
    if (confirm('确定删除该数据吗？')){
      productArr.value.splice(index,1);
    }
  }
</script>

<template>
  <ul>
    <li v-for="item in 10">{{item}}</li>
  </ul>
  <ul>
    <li v-for="p in productArr">{{p}}</li>
  </ul>
  <hr>
  <table border="1px">
    <tr>
      <th>商品编号</th>
      <th>商品名称</th>
      <th>商品价格</th>
      <th>商品库存</th>
      <th>操作</th>
    </tr>
    <tr v-for="(item,index) in productArr">
      <td>{{index+1}}</td>
      <td>{{item.title}}</td>
      <td>{{item.price}}</td>
      <td>{{item.count}}</td>
      <td><button @click="del(index)">删除</button></td>
    </tr>
  </table>
</template>

<style scoped>

</style>